﻿Imports MySql.Data.MySqlClient

Public Class frmadd_vessel
    Dim mySqlCommand As New MySqlCommand
    Dim mySqlAdaptor As New MySqlDataAdapter
    Dim mySqlReader As MySqlDataReader
    Dim respone As Object
    Dim mysql As MySqlConnection = main_form.mysqlconection
    Private Sub ButtonX1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
        mySqlCommand = New MySqlCommand
        respone = MsgBox("ยืนยันข้อมูลถูกต้อง", MsgBoxStyle.OkCancel + MsgBoxStyle.Information, "Warning Messsage")
        If respone = 1 Then
            Try
                mySqlCommand.Parameters.Clear()
                mySqlCommand.CommandText = "insert into VESMAIN ( VSSNAM, VSSMASTER, VSSNATION, VSSINS,VSSDATE) values (@VSSNAM,@VSSMASTER,@VSSNATION,@VSSINS,@VSSDATE)"
                mySqlCommand.Connection = mysql


                mySqlCommand.Parameters.AddWithValue("@VSSNAM", txt_vessel.Text)
                mySqlCommand.Parameters.AddWithValue("@VSSMASTER", txt_namemaster.Text)
                mySqlCommand.Parameters.AddWithValue("@VSSNATION", txt_nationality.Text)
                mySqlCommand.Parameters.AddWithValue("@VSSINS", txt_insurance.Text)
                mySqlCommand.Parameters.AddWithValue("@VSSDATE", date_eta.Value.Date.ToString("dd-MM-yyyy"))
                mySqlCommand.ExecuteNonQuery()

                mysql.Close()
                txt_vessel.Text = ""
                txt_namemaster.Text = ""
                txt_nationality.Text = ""
                txt_insurance.Text = ""
                date_eta.Value = Date.Now

                MsgBox("Save Complete")
            Catch ex As Exception

            End Try
        End If



    End Sub

    Private Sub frmadd_vessel_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US")
        System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture
        mysql.Close()
        If mysql.State = ConnectionState.Closed Then
            mysql.Open()
        End If
    End Sub

  

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Sub ChangFocus(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt_vessel.KeyPress, txt_namemaster.KeyPress, txt_nationality.KeyPress, txt_insurance.KeyPress
        If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
            SendKeys.Send("{TAB}")
            e.Handled = True
        End If
    End Sub
End Class